from django.shortcuts import render
from rest_framework import viewsets

from apps.movie.models import Movie,Category
from apps.movie.serializers import MovieSerializer,CategorySerializer

from django_filters import rest_framework as filters

class MovieFilter(filters.FilterSet):
    movie_name = filters.CharFilter(field_name='movie_name', lookup_expr='icontains')
    class Meta:
        model = Movie
        fields = ['movie_name']

# Create your views here.
class MovieViewSet(viewsets.ModelViewSet):
    queryset = Movie.objects.all()
    serializer_class = MovieSerializer

    filter_backends = (filters.DjangoFilterBackend,)
    filterset_class  = MovieFilter


class CategoryViewSet(viewsets.ModelViewSet):
    queryset = Category.objects.all()
    serializer_class = CategorySerializer

